import java.util.ArrayList;
import java.util.List;


public class DarrellPod implements MusicPlayer {
	
	private List<Song> allSongs;
	private int currentSongPosition;
	
	public DarrellPod() {
		allSongs = new ArrayList<Song>();
		currentSongPosition = -1;
	}

	@Override
	public void addSong(Song someSong) {
		allSongs.add(someSong);
		
	}

	@Override
	public void playNextSong() {
		int lastSongPosition = allSongs.size() -1;
		if(currentSongPosition == lastSongPosition) {
			currentSongPosition = 0;
			return;
		}
		
		currentSongPosition++;
	}

	@Override
	public void playPreviousSong() {
		int firstSongPosition = 0;
		if(currentSongPosition == firstSongPosition) {
			int lastSongPosition = allSongs.size() -1;
			currentSongPosition = lastSongPosition;
			return;
		}

		currentSongPosition--;		
	}

	@Override
	public int size() {
		int numberOfItems = allSongs.size();
		return numberOfItems;
	}

	@Override
	public Song getSong(int position) {
		Song aSong = allSongs.get(position);
		return aSong;
	}

	@Override
	public Song getCurrentSong() {
		if(currentSongPosition == -1) {
			return new Song("No Song", "No Song", 0);
		}
		
		Song currentSong = allSongs.get(currentSongPosition);

		return currentSong;
	}

}
